#pragma once
#include "Ticket.h";
#include <string>
#include <iterator>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <fstream>

using namespace std;
typedef array<int, 5> flrIntArray;
typedef array<double, 5> flrDblArray;

class StatPack
{
public:
	StatPack(void);
	StatPack(int elevCount, string fileName, bool flag);
	~StatPack(void);
	bool processDataPoint(Ticket * ticket);
	bool CalcStats();
	bool writeSimData(void);
	bool init(int runID);
private:
	// Constants
	const int the95PercentileNumber;	// The index value in the wait list for the 95 percentile point
	const int targetWaitTime;			// The time desired that less than 
	// Run data values
	priority_queue <int> waitList;		// Storage container for wait times.
	vector<flrIntArray> ElstatsCount;	// The count of passengers delivered to each floor by each elevator
	vector<flrDblArray> ElstatsWait;	// mean wait time for each floor for each elevator
	vector<flrIntArray> ElstatsWaitMin;	// minimum wait time for each floor for each elevator
	vector<flrIntArray> ElstatsWaitMax;	// maximum wait time for each floor for each elevator
	int runMinWait;						// shortest wait time for this run
	int runMaxWait;						// longest wait time for this run
	double meanWaitTime;				// The mean wait time calculated for this run.
	double the60SecCount;				// The percentile point of passengers with less than 60 second wait times for this run
	double percentileWaitTime;			// The wait time at the 95% point for this run.
	// Combined data values
	vector<flrDblArray> avgElstatsWait;		// Holds average wait times for each floor for each elevator
	vector<flrIntArray> avgElstatsWaitMin;	// Holds minimum wait times for each floor for each elevator
	vector<flrIntArray> avgElstatsWaitMax;	// Holds max wait times for each floor for each elevator
	vector<flrDblArray> avgElstatsCount;	// Holds the average passengers delivered by floor for each elevator
	vector<flrIntArray> avgElstatsCountMin;	// Holds the minimum number of passengers delivered by floor for each elevator
	vector<flrIntArray> avgElstatsCountMax;	// Holds the maximum number of passengers delivered by floor for each elevator
	array<double,3> avgMeanWaitTime;		// Holds minimum, maximum, and averaged total mean wait time
	array<double,3> avg60SecCount;			// Holds minimum, maximum, and averaged percentage of passengers with less than 60 second wait times
	array<double,3> avgPercentile;			// Holds minimum, maximum, and averaged wait time at the 95% point
	// Support variables
	int runNum;				// The run number
	int eCount;				// The number of elevators being simulated
	string baseFileName;	// A common string used as the base for creating the data file names.
	bool writeFlag;			// Flag the allows or forbids writing the run data.
	fstream runDataFile;	// Filesteam variable used to create the data files.	

};

